package 寒假作业.LeetCode;

import stack_queue.stack.Stack;

public class 剑指offer06 {

      public class ListNode {
          int val;
          ListNode next;
          ListNode(int x) { val = x; }
      }

    public int[] reversePrint(ListNode head) {
          //用一个栈
        Stack<ListNode> stack = new Stack<ListNode>();
        ListNode node = head;
        while (node != null){
            stack.push(node);
            node = node.next;
        }
        int size = stack.getSize();
        int[] print = new int[size];
        for (int i = 0; i < size; i++) {
            print[i] = stack.pop().val;
        }
        return print;
    }


}
